package com.spring.service.person.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.spring.web.formbean.person.PersonOtherForm;
import com.spring.bean.person.PersonOther;
import com.spring.dao.person.PersonOtherDao;
import com.spring.bean.page.Page;
import com.spring.bean.page.PageView;
import com.spring.service.ServiceSupport;
import com.spring.service.person.PersonOtherService;
import com.spring.exception.ServiceException;

@Service
@Transactional
public class PersonOtherServiceImpl extends ServiceSupport implements PersonOtherService {

	@Autowired
	private PersonOtherDao personOtherDao;

	/** insert */
	public boolean insert(PersonOtherForm personOtherForm) throws ServiceException {
		try{
			PersonOther personOther = formToEntity(PersonOther.class, personOtherForm);
			return personOtherDao.insert(personOther);
		} catch (Exception e) {
			throw new ServiceException("PersonOther --- insert error", e);
		}
	}

	/** update */
	public boolean update(PersonOtherForm personOtherForm) throws ServiceException {
		try{
			PersonOther personOther = formToEntity(PersonOther.class, personOtherForm);
			return personOtherDao.update(personOther);
		} catch (Exception e) {
			throw new ServiceException("PersonOther --- update error", e);
		}
	}

	/** delete */
	public boolean delete(Integer id) throws ServiceException {
		try{
			return personOtherDao.delete(id);
		} catch (Exception e) {
			throw new ServiceException("PersonOther --- delete error", e);
		}
	}

	/** getById */
	public PersonOther getById(Integer id) throws ServiceException {
		try{
			return personOtherDao.getById(id);
		} catch (Exception e) {
			throw new ServiceException("PersonOther --- query by id error", e);
		}
	}

	/** queryForList */
	public List<PersonOther> queryForList() throws ServiceException {
		try{
			return personOtherDao.queryForList();
		} catch (Exception e) {
			throw new ServiceException("PersonOther --- query list error", e);
		}
	}

	/** queryForPage */
	public PageView<PersonOther> queryForPage(Page page) throws ServiceException {
		try{
			return personOtherDao.queryForPage(page);
		} catch (Exception e) {
			throw new ServiceException("PersonOtherForm ---query page error", e);
		}
	}
}